﻿<!DOCTYPE html>
<html>
<head>
<%
    include("/static/include/title.html"){}
    include("/static/include/css.html"){}
    include("/static/include/js.html"){}
%>
</head>

<body>
<div class="layui-fluid">
	<form id="fAdd" class="layui-form" action="#" onsubmit="return false" method="post">
		<input type="hidden" id="dialogId" name="dialogId" value="${parameter.dialogId}"/>

		<div class="layui-card">
			<!-- 如需要header信息，放开下面的comment -->
			<!-- <div class="layui-card-header">基础信息</div> -->
			<div class="layui-card-body" style="padding: 15px;">
				<!-- 如一行显示多列数据，参照下面的示例 -->
				<!-- 
				<div class="layui-form-item">
					<div class="layui-inline">
						<label class="layui-form-label">属性1：</label>
						<div class="layui-input-inline">
							<input type="text" autocomplete="off" class="layui-input" maxlength="25" title="属性1对应控件">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">属性2：</label>
						<div class="layui-input-inline">
							<input type="text" autocomplete="off" class="layui-input" maxlength="25" title="属性1对应控件">
						</div>
					</div>
				</div>
				-->

				<div class="layui-form-item">
					<label class="layui-form-label" style="width:180px;">数据库配置：</label>
					<div class="layui-input-inline">
                        <select style="width:460px;" name="warningConfig.dbAlias" lay-verify="" placeholder="数据库配置" lay-filter="test">
                            <% if(has(dbAliasList) && dbAliasList != null && !isEmpty(dbAliasList)){ %>
                            <% for(i in dbAliasList) {
                                if ("application" == i) {%>
                                <option value="${i}" selected>${i}</option>
                            <% } else{ %>
                             <option value="${i}">${i}</option>
                            <% }}}
                            else {%>
                                <option value="">无可用数据库</option>
                            <% } %>
                        </select>
					</div>
				</div>
	  
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:180px;">提醒信息格式<span style="color:#FF5722;">*</span>：</label>
					<div class="layui-input-inline">
						<input style="width:460px;" type="text" name="warningConfig.tip" placeholder="提醒信息格式（如：您有{COUNT}个XXX需要处理）" value="${@team.bangbang.common.utility.LogicUtility.getQuotedString(warningConfig.tip)}" autocomplete="off" class="layui-input" maxlength="50">
					</div>
				</div>
	  
				<div class="layui-form-item">
					<label class="layui-form-label" style="width:180px;">关联菜单<span style="color:#FF5722;">*</span>：</label>

					<div class="layui-input-inline" style="width:330px;">
                        <input disabled style="width:330px;display: inline-block;" id="selectMenuName" type="text" name="warningConfig.menu.menuName" placeholder="选择菜单" value="${warningConfig.menu.menuName!}" autocomplete="off" class="layui-input" maxlength="8" >
                    </div>
                    <div class="layui-input-inline" style="margin:0;padding: 0;width:120px;">
                        <button style="margin:0;padding: 0;width:120px;display: inline-block;" class="layui-btn layui-btn-primary" onclick="openSelectMenuDialog('选择关联菜单', 'menu', 750, 600);">选择菜单</button>
                    </div>

                    <div class="layui-input-inline" style="display: none;">
                        <input style="width:460px;" id="selectMenuId" type="text" name="warningConfig.menuId" placeholder="关联菜单" value="${warningConfig.menuId}" autocomplete="off" class="layui-input" maxlength="8" >
                    </div>
				</div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="width:180px;">统计查询的SQL语句<span style="color:#FF5722;">*</span>：</label>
                    <!--<div class="layui-input-block">
                        <textarea style="width:460px;" name="warningConfig.querySql" placeholder="统计查询的SQL语句" value="${@team.bangbang.common.utility.LogicUtility.getQuotedString(warningConfig.querySql)}" autocomplete="off" class="layui-textarea" maxlength="500"></textarea>
                    </div>-->
                </div>
                <div class="layui-form-item">
                    <div class="" style="padding-left: 28px; margin-top: -18px">
                        <ol type="1">
                            <li><span>1.</span><span style="color: red">{CURRENT_USER_ID}</span><span>: 当前操作用户编号</span></li>
                            <li><span>2.</span><span style="color: red">{CURRENT_USER_ORG_ID}</span><span>: 当前操作用户组织编号</span></li>
                            <li><span>3.</span><span style="color: red">{CURRENT_USER_ORG_CODE}</span><span>: 当前操作用户组织编码</span></li>
                            <!-- <li><span>4.</span><span style="color: red">{AUDIT_TASK_FILTER:BizFlag=[BizFlag]}</span><span>: 当前操作用户的审批任务过滤条件，其中[BizFlag]表示单数字标识</span></li> -->
                            <li><span>4.</span><span style="color: red">{IN_MY_ORGANIZATION:FieldName=[FieldName]}</span><span>: 当前操作用户管理的组织过滤条件，其中[FieldName]表示限定字段名称</span></li>
                            <li><span>5.</span><span style="color: red">&lt;if hasRoleId="  "&gt;&lt;/if&gt;&lt;else&gt;&lt;/else&gt;</span><span>: 当前操作用户是否拥有某个角色，如果有执行if，否则执行else</span></li>
                        </ol>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="">
                        <textarea style="width: 96%;margin-left: 3%;height: 200px;" name="warningConfig.querySql" placeholder="统计查询的SQL语句" value="${@team.bangbang.common.utility.LogicUtility.getQuotedString(warningConfig.querySql)}" autocomplete="off" class="layui-textarea" maxlength="500"></textarea>
                    </div>
                </div>
			</div>
		</div>
		
		<div class="layui-form-item layui-layout-admin">
			<div class="layui-input-block">
				<div class="layui-footer" style="left: 0;">
					<button class="layui-btn" onclick="doAddAction('warningConfig');">新 增</button>
				</div>
			</div>
		</div>
	</form>
</div>
<script>
	layui.use(['form','laydate'], function(){
        var form  = layui.form;
        var laydate = layui.laydate;
        // 渲染表单radio、select、checkbox
        form.render();

    });

	function validate(theForm) {
		// 注意：
		// 如果更改页面表单的控件类型，请在校验判断时做对应修改：
		// 1. 下拉框：使用 $.trim(theForm["控件名称"].value) == ""
		// 2. 单选框/复选框：使用 getChoiceValue("控件名称") == null
		// 
	
		var warningConfigDbAlias = $.trim(theForm["warningConfig.dbAlias"].value);

//		if(warningConfigDbAlias != "" && !isPositiveInteger(warningConfigDbAlias)) {
//			layer.msg("数据库配置必须为正整数！");
//			return false;
//		}
	
		if($.trim(theForm["warningConfig.tip"].value) == "") {
			$.message("提醒信息格式不能为空！");
			return false;
		}
	
		var warningConfigMenuId = $.trim(theForm["warningConfig.menuId"].value);
	
		if(warningConfigMenuId == "") {
			$.message("关联菜单不能为空！");
			return false;
		}
	
		if(warningConfigMenuId != "" && !isPositiveInteger(warningConfigMenuId)) {
			layer.msg("关联菜单必须为正整数！");
			return false;
		}
	
		if($.trim(theForm["warningConfig.querySql"].value) == "") {
			$.message("统计查询的SQL语句不能为空！");
			return false;
		}
		return true;
	}
	function openSelectMenuDialog(title, baseUrl, width, height) {
        var url = getFullUrl(baseUrl +"Select.do");
        openDialog(title, url, width, height, function(data) {
            if (data != null && data.data != null) {
                document.getElementById('selectMenuId').value = data.data.id;
                document.getElementById('selectMenuName').value = data.data.name;
            }
        });
    }
</script>
</body>
</html>
